//
//  ATVEditorView.m
//  FlashController
//
//  Created by Martin Schiøth Dyrby on 11/15/11.
//  Copyright 2011 Molamil. All rights reserved.
//

#import "ATVEditorView.h"
#import "ATVInstance.h"

@implementation ATVEditorView
@synthesize instances;

- (void) updateEditorView:(NSArray*) newInstances
{
    if(self.dataSource == NULL) 
    {
        [self setDataSource:self];
    }

    instances = newInstances;
    [self reloadData];
}

/* EDITOR VIEW DATASOURCE */

- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView 
{
    return instances.count;
}

- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
    if (rowIndex > instances.count) {
        return nil;
    }
    
    ATVInstance *instance = [instances objectAtIndex:rowIndex];
    NSString *label = instance.path;
    //[instance release];
    return label;
}

- (NSCell *)preparedCellAtColumn:(NSInteger)column row:(NSInteger)row {
    NSTextField* cell = (NSTextField*)[super preparedCellAtColumn:column row:row];
    [cell setEditable:NO];
    return (NSCell *)cell;
}

@end
